#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int Judge(char* s1,int i)
{
    if (isdigit(s1[i]) || (s1[i] >= 'A' && s1[i] <= 'Z') || (s1[i] >= 'a' && s1[i] <= 'z'))
        return 0;
    return 1;
}
void change1(char* s1)
{
    int len = strlen(s1);
    for (int i = 0; i < len; i++)
    {
        if (s1[i] == ' ' && Judge(s1, i + 1))
        {
            char tmp[100] = { 0 };
            strcpy(tmp, s1 + i + 1);
            s1[i] = '\0';
            strcat(s1, tmp);
        }
    }
}
void change(char* s1)
{
    char s[4][10] = { "can you","could you","I can","I could" };
    char tmp[100] = { 0 };
    for (int i = 0; i < 2; i++)
    {
        int len = strlen(s[i]);
        char* ret = strstr(s1, s[i]);
        if (ret != NULL)
        {
            *ret = '\0';
            strcpy(tmp, ret + len);
            strcat(s1, s[i + 2]);
            strcat(s1, tmp);
        }
    }
}
void change2(char* s1)
{

}
int main()
{
    int n, m = 0;
    char s[1000] = { 0 };
    char s1[100] = { 0 };
    scanf("%d", &n);
    getchar();
    for (int i = 0; i < n; i++)
    {
        gets(s);
        printf("%s\n", s);
        printf("AI: ");
        int len = strlen(s);
        m = 0;
        for (int j = 0; j < len; j++)
        {
            if (j == 0)
            {
                while (s[j] == ' ')
                {
                    j++;
                }
                j--;
            }
            else
            {
                if (s[j] == ' ')
                {
                    s1[m] = s[j];
                    m++;
                    j++;
                    while (s[j] == ' ')
                    {
                        j++;
                    }
                    j--;
                }
                if (s[j] == '?')
                {
                    s1[m] = '!';
                    m++;
                }
                if (s[j] == '\''&&s[m-1]==' ')
                {
                    m--;
                    s[m] = '\'';
                    m++;
                }
                if (s[j] != '?' && s[j] != ' ')
                {
                    if (isupper(s[j]) && s[j] != 'I')
                    {
                        s1[m] = tolower(s[j]);
                        m++;
                    }
                    else
                    {
                        s1[m] = s[j];
                        m++;
                    }
                }

            }
        }
        change(s1);
        change1(s1);
        change3(s1);
        printf("%s\n", s1);
    }
    return 0;
}